<template>
  <div class="app-container">
    <el-row :gutter="24">
      <div class="header">
        <span class="dia"></span>
        <strong>基本信息</strong>
      </div>
      <el-form  :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="用户名称:" prop="name">
          <el-col :span="4" >
            <div class="pull-left">{{ user.userName }}</div>
          </el-col>
        </el-form-item>
        <el-form-item label="手机号码:" required>
          <el-col :span="4" >
            <el-input
              type="text"
              placeholder="请输入手机号码"
              v-model="user.phonenumber"
              size="small"
              style="width: 200px"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="用户邮箱:" required >
          <el-col :span="4" >
            <el-input
              type="text"
              placeholder="请输入邮箱号码"
              v-model="user.email"
              size="small"
              style="width: 200px"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="所属部门:">
          <el-col :span="4" >
            <div class="pull-left" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
          </el-col>
        </el-form-item>
        <el-form-item label="所属角色:">
          <el-col :span="4" >
            <div class="pull-left">{{ roleGroup }}</div>
          </el-col>
        </el-form-item>
        <el-form-item label="创建日期:" >
          <el-col :span="4" >
            <div class="pull-left">{{ user.createTime }}</div>
          </el-col>
        </el-form-item>
        <el-form-item label="性别:">
          <el-col :span="4">
            <el-radio-group v-model="user.sex">
              <el-radio label="0">男</el-radio>
              <el-radio label="1">女</el-radio>
            </el-radio-group>
          </el-col>
        </el-form-item>
      </el-form>
      <el-divider></el-divider>
      <div class="header">
        <span class="dia"></span>
        <strong>基本资料</strong>
      </div>
      <resetPwd :user="user" />
    </el-row>
  </div>
<!--  <div class="app-container">-->
<!--    <el-row :gutter="20">-->
<!--      <el-col :span="6" :xs="24">-->
<!--        <el-card class="box-card">-->
<!--          <div slot="header" class="clearfix">-->
<!--            <span class="dia"></span>-->
<!--            <span>基本信息</span>-->
<!--          </div>-->
<!--          <div>-->
<!--&lt;!&ndash;            <div class="text-center">&ndash;&gt;-->
<!--&lt;!&ndash;              <userAvatar :user="user" />&ndash;&gt;-->
<!--&lt;!&ndash;            </div>&ndash;&gt;-->
<!--            <ul class="list-group list-group-striped">-->
<!--              <li class="list-group-item">-->
<!--                <svg-icon icon-class="user" />&nbsp;&nbsp;用户名称-->
<!--                <div class="pull-right">{{ user.userName }}</div>-->
<!--              </li>-->
<!--              <li class="list-group-item">-->
<!--                <svg-icon icon-class="phone" />&nbsp;&nbsp;手机号码-->
<!--                <div class="pull-right">{{ user.phonenumber }}</div>-->
<!--              </li>-->
<!--              <li class="list-group-item">-->
<!--                <svg-icon icon-class="email" />&nbsp;&nbsp;用户邮箱-->
<!--                <div class="pull-right">{{ user.email }}</div>-->
<!--              </li>-->
<!--              <li class="list-group-item">-->
<!--                <svg-icon icon-class="tree" />&nbsp;&nbsp;所属部门-->
<!--                <div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>-->
<!--              </li>-->
<!--              <li class="list-group-item">-->
<!--                <svg-icon icon-class="peoples" />&nbsp;&nbsp;所属角色-->
<!--                <div class="pull-right">{{ roleGroup }}</div>-->
<!--              </li>-->
<!--              <li class="list-group-item">-->
<!--                <svg-icon icon-class="date" />&nbsp;&nbsp;创建日期-->
<!--                <div class="pull-right">{{ user.createTime }}</div>-->
<!--              </li>-->
<!--            </ul>-->
<!--          </div>-->
<!--        </el-card>-->
<!--      </el-col>-->
<!--      <el-col :span="18" :xs="24">-->
<!--        <el-card>-->
<!--          <div slot="header" class="clearfix">-->
<!--            <span>基本资料</span>-->
<!--          </div>-->
<!--          <el-tabs v-model="activeTab">-->
<!--            <el-tab-pane label="基本资料" name="userinfo">-->
<!--              <userInfo :user="user" />-->
<!--            </el-tab-pane>-->
<!--            <el-tab-pane label="修改密码" name="resetPwd">-->
<!--              <resetPwd :user="user" />-->
<!--            </el-tab-pane>-->
<!--          </el-tabs>-->
<!--        </el-card>-->
<!--      </el-col>-->
<!--    </el-row>-->
<!--  </div>-->
</template>

<script>
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import { getUserProfile } from "@/api/system/user";

export default {
  name: "Profile",
  components: { userAvatar, userInfo, resetPwd },
  data() {
    return {
      user: {},
      roleGroup: {},
      postGroup: {},
      activeTab: "userinfo"
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    }
  }
};

</script>
<style scoped>
  .text-center{
    display: flex;
    justify-content: center;
    margin: -10px 0 10px 0;
  }
  .dia {
    width: 5px;
    height: 15px;
    display: inline-block;
    background: #0099ff;
    margin-right: 10px;
  }
  .header {
    margin-bottom: 20px;
    display: flex;
  }
</style>
